package com.csweimei.rentmanagementtreasure.tenant.ui.act;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProviders;

import android.content.Intent;
import android.os.Bundle;

import com.chad.library.BR;
import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.base.AppViewModelFactory;
import com.csweimei.rentmanagementtreasure.databinding.ActivityFollowHouseBinding;
import com.csweimei.rentmanagementtreasure.http.entity.HouseListBean;
import com.csweimei.rentmanagementtreasure.tenant.viewModel.FollowHouseVM;

import me.goldze.mvvmhabit.base.BaseActivity;

public class FollowHouseActivity extends BaseActivity<ActivityFollowHouseBinding, FollowHouseVM> {


    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_follow_house;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.setActivity(this);
    }

    @Override
    public FollowHouseVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this,factory).get(FollowHouseVM.class);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == 10087){
            HouseListBean.DataDTO.ArrDTO bean = (HouseListBean.DataDTO.ArrDTO) data.getSerializableExtra("data");
            viewModel.housingID.set(bean.getId()+"");
            viewModel.housingMsg.set(bean.getTitle());
        }
    }
}